#Makefile "borrowed" from one of Ayla's Projects.

BINARY:=flamefront

CROSS_COMPILE ?= mipsel-linux-
CC := $(CROSS_COMPILE)gcc

INIPARSER=../iniparser

OBJS= src/main.o \
      src/menu.o \
      src/items.o \
      src/callbacks.o \
      src/xmlLoader.o \
      src/settings.o 
      

CFLAGS?=-Wall -O2
DEBUG ?= 0
CFLAGS+=-I/usr/include/libxml2/ -I/usr/include/SDL/ -I$(INIPARSER)/src/ -Wno-pointer-sign -Wno-implicit-function-declaration

ifeq ($(DEBUG),1)
	CFLAGS+=-DDEBUG
endif

GDB:=gdb
INCLUDES:=
LDFLAGS?=-s
LDFLAGS+= 
LIBS:=-lSDL -lSDL_image -lSDL_ttf -lxml2 -lc -lconfuse -L $(INIPARSER) -liniparser


.PHONY: all clean

all: $(BINARY)	

$(BINARY): $(OBJS)
	$(CC) $(addprefix -Wl,,$(LDFLAGS)) -o $@ $(OBJS) $(LIBS)

$(OBJS): %.o: %.c
	$(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<

clean:
	rm -f $(BINARY) $(OBJS)

debug:	
	make clean
	CFLAGS="-Wall -ggdb" LDFLAGS="-ggdb" DEBUG=1 CROSS_COMPILE='' make
	$(GDB) -quiet $(BINARY)

run:
	make clean
	CFLAGS="-Wall -O2" LDFLAGS="-s" DEBUG=1 CROSS_COMPILE='' make
	./$(BINARY)

rel:	
	make clean
	make
	$(CROSS_COMPILE)strip $(BINARY)
